import http from "@/axios";
import type {BaseResponse} from "@/api/baseResponse";

enum ApiUrl {
    getLatestDataUrl = "/statistics/latest/data",
    listLatestDataUrl = "/statistics/latest/data/list"
}

interface LatestDataResponse {
    msgInflow: number;
    msgOutflow: number;
    connect: number;
    onlineConnect: number;
    topics: number;
    subscriptions: number;
    dateTime: string;
}

export function getLatestData() {
    return http.get<BaseResponse<LatestDataResponse>>(ApiUrl.getLatestDataUrl);
}

export function listLatestData(latest: number) {
    return http.get<BaseResponse<LatestDataResponse[]>>(ApiUrl.listLatestDataUrl, {
        params: {
            latest: latest
        }
    })
}